#pragma once
#include "tgaimage.h"
#include "geometry.h"

auto viewport(int x, int y, int w, int h) -> void;
void projection(double coeff=0); // coeff = -1/c
void lookat(const vec3 &eye, const vec3 &center, const vec3 &up);

struct IShader {
    virtual ~IShader() = default;

    static TGAColor sample2D(const TGAImage &img, vec2 &uvf) {
        return img.get(static_cast<int>(uvf[0] * img.width()), static_cast<int>(uvf[1] * img.height()));
    }
    virtual bool fragment(vec3 bar, TGAColor &color) = 0;
};

void triangle(const vec4 clip_verts[3], IShader &shader, TGAImage &image, std::vector<double> &zbuffer);

